<?php 
    #######################################
	#  LISTE DES FORMULAIRES GENERES      #
	#######################################
	session_start();
	header("Expires: -1");
	header("Content-type: text/html; charset=iso-8859-1");
	//putenv("TZ=US/Eastern");
	require_once "../db/mysql/tbr.php";
	require_once "../classes/forms.cls.php";
	require_once "../classes/users.cls.php";
	require_once "../conf/config.php";
	require_once('../'.$LANG_FILE);
	
	/****  CONNECTION TO RDBMS SERVER ****/	
	require_once "../db/mysql/tbr.ini.php";
	/***********************************/
	
	$form = new svq_form();
	$formTable = "svq_forms";
	$usersTable = "svq_users";
	$usersFormsTable = "svq_users_forms";	
	$userId = isset($_SESSION['ui'])?$_SESSION['ui']:svq_user::getDemoId($base,$usersTable);
	$_allForms = $form->__allByUser($base,$formTable,$usersTable,$usersFormsTable,$userId);
	$result="";
	$i=0;
	
	$result.="<table id='allForms'>";
	$result.="<tr>";	
	$result.='<th class="COBO">';
	$result.="Titre";
	$result.="</th>";	
	$result.="<th>";
	$result.="Nb Objets";
	$result.="</th>";
	$result.="<th>";
	$result.="Creation";
	$result.="</th>";
	$result.="<th>";
	$result.="modif";
	$result.="</th>";
	$result.="<th>";
	$result.="options";
	$result.="</th>";
	$result.="</tr>";	
	if(is_array($_allForms)){
		foreach($_allForms as $form){			
			$currentStyle=($i%2)?'all_l1':'all_l2';
			$result.="<tr>";			
			$result.="<td class='".$currentStyle."_ all_x' onClick=listenToFormList('".$form['id']."','".$form['sid']."');  id='".$form['sid']."'>";
			$result.=stripslashes($form['title']);
			$result.="</td>";			
			$result.="<td class='".$currentStyle."'>";
			$result.=$form['total'];
			$result.="</td>";
			$result.="<td class='".$currentStyle."'>";
			$result.=date('d/m/Y H:i:s',$form['datecre']);
			$result.="</td>";
			$result.="<td class='".$currentStyle."'>";
			$result.=(!empty($form['datemod']))?date('d/m/Y H:i:s',$form['datemod']):'';
			$result.="</td>";
			$result.="<td class='".$currentStyle."'>";
			$id = $form['id'];
			$sid = $form['sid'];
			$result.='<a href="?gts=11&fid='.$sid.'" target="_blank"><img src="images/layout.png"  class="generatedFormPage" title="html page .:'.$form['desc'].':."/>&nbsp;&nbsp;</a>';
			$result.='<img src="images/cross.png" class="formDel" title="delete" onClick="confirm(\''.TXT_113.'\')?deleteFormFromList(\''.$id.'\'):false"/>';			
			$result.="</td>";
			$result.="</tr>";
			$i++;
		}		
	}else echo '<tr><td colspan="5"><span style="text-align:center;font-bold:bold;">No form generated !!! </span></td></tr>';	
	echo $result.="</table>";
?>